﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections;

namespace WPF101_GetStarted
{
    /// <summary>
    /// Interaction logic for DataTpl.xaml
    /// </summary>
    public partial class DataTpl : Window
    {
        List<MyTask> mytasks = null;

        public DataTpl()
        {
            InitializeComponent();


            // create a new list and specify value
            mytasks = new List<MyTask>()
            {
                new MyTask { Description="task3", Priority="High", TaskName="task3" },
                new MyTask { Description="task2", Priority="Low", TaskName="task2" },
                new MyTask { Description="task1", Priority="Medium", TaskName="task1"}
            };
            this.DataContext = mytasks;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            mytasks.Add(new MyTask() { Description = "task4", Priority = "High", TaskName = "task4" });
            mytasks[0].Description = "Update the task";
        }
    }

    public class MyTask
    {
        public string TaskName { get; set; }
        public string Description { get; set; }
        public string Priority { get; set; }
        public override string ToString()
        {
            return TaskName + " " + Description + " " + Priority;
        }
    }
}
